'''
    自动取款机系统
    1.用户信息数据源
    2.查看银行卡余额
    3 存款
    4 取款
    5 退出系统
    6 登录界面和交互
'''
# 1 用户信息数据源
user_list1=[
    {'user':'wzj','password':'python1',},
    {'user':'lbs','password':'python2',},
    {'user':'lbl','password':'python3',}]
user_list2=[
    {'user':'wzj','balance':6666666.888},
    {'user':'lbs','balance':8888888.666},
    {'user':'lbl','balance':6868686.868}]
# 生成用户的余额信息字典
user_dict1 = {}
for idict in user_list2:
    t_user = list(idict.values())
    user_dict1[t_user[0]] = t_user[1]

# 2 查看银行卡余额
def show_blance(user):
    print("{:=^20}".format('余额查询'))
    print('{:2}您的余额为 {:10} {:2}'.format('-', user_dict1[user], '-'))

# 3 存款页面
def add_blance(user):
    print("{:=^20}".format('存款'))
    a = input("请输入要存取的金额：")
    user_dict1[user] = eval(a) + user_dict1[user]
    print("请放入您的钱")
    print('{:2}您的余额为 {:10} {:2}'.format('-', user_dict1[user], '-'))

# 4 取款页面
def del_blance(user):
    print("{:=^20}".format('取款'))
    a = input("请输入要取出的金额：")
    user_dict1[user] = user_dict1[user] - eval(a)
    print("请取走您的钱")
    print('{:5} {:10} {:5}'.format('-', user_dict1[user], '-'))

# 5 退出系统
def loginOut():
    pass

# 6 登入界面和交互
def main():
    print("{:=^20}".format('自动取款机'))
    a = input("请输入您的用户名：")
    b = input("请输入您的密码：")
    user_dict = {}
    user_dict['user'] = a
    user_dict['password'] = b
    if user_dict in user_list1:
        while True:
            # 输出初始界面
            print("{:=^20}".format('自动取款机'))
            print('{:1} {:9} {:9}'.format(' ', '1.查询余额', '2.存款'))
            print('{:1} {:9} {:9}'.format(' ', '3.取款', '4.退出'))
            print('=' * 20)
            key = input("请输入对应的选择")
            if key == '1':
                show_blance(a)
                input("按回车继续：")
            elif key == '2':
                add_blance(a)
                input("按回车继续：")
            elif key == '3':
                del_blance(a)
                input("按回车继续：")
            elif key == '4':
                loginOut()
                print("{:=^20}".format('再见'))
                break
            else:
                print("{:=^20}".format('操作无效'))
    else:
        print('输入错误，请重新输入')
        main()
main()


